import { Switch, Route, Redirect } from "react-router-dom"
import React, { Component } from 'react'

class RouterView extends Component {
    render() {
        const { routes } = this.props
        return (
            <Switch>
                {
                    routes.length && routes.map((v, i) => {
                        return (
                            v.path ?
                                <Route path={v.path} key={i} render={props => <v.component {...props} routes={v.children}></v.component>}></Route>
                                : <Redirect from={v.from} to={v.to} key={i}></Redirect>
                        )
                    })
                }
            </Switch>
        )
    }
}
export default RouterView